package com.hisense.proxy.busitrans.vo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class BaseResponse<T> {
    /**
     * 操作成功时的data返回值
     */
    public static final String SUCCESS_TIP = "Success";

    /**
     * 操作失败时的data返回值
     */
    public static final String FAILURE_TIP = "Failure";

    Integer code = 1000;

    List<Map> eventTags = new ArrayList<>();


    String message = "";

    T data;

    Long page = 0L;

    Long total = 0L;

    public BaseResponse<T> setError(String msg) {
        code = 500;
        this.message = msg;

        return this;
    }

    public BaseResponse<T> setValidationConstraintErr(String msg) {
        code = 500;
        message = msg;

        return this;
    }

    public BaseResponse<T> setOk() {
        code = 1000;
        return this;
    }


    public BaseResponse<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public BaseResponse<T> appendMessage(String message) {
        this.message = this.message + message;
        return this;
    }

    public BaseResponse<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    public BaseResponse<T> setData(T t) {
        data = t;
        return this;
    }

    public BaseResponse<T> setPage(Long t) {
        page = t;
        return this;
    }

    public BaseResponse<T> setTotal(Long t) {
        total = t;
        return this;
    }

    /**
     * 添加新的事件标识
     * @param event
     * @return
     */
    public BaseResponse<T> appendNewEvent(Map event) {
        eventTags.add(event);
        return this;
    }


}
